<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--#include file="DataLoad.asp"-->
<%Call CheckAdmin2()%>

<html>
<head>
<title><%=GuildName%> - DKP系统</title>
<script language="JavaScript" src="inc/jquery.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="Generator" content="EditPlus">
<meta name="Author" content="SULei">
<meta name="Keywords" content="DKP WOW GUILD">
<meta name="Description" content="">
<link href="<%=StylePath%>/main.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="<%=StylePath%>/styleplus.js"></script>
<style type="text/css" media="all">

</style>
</head>

<body>

<div class="header">
<!--#include file="menu.asp"-->
</div>
<div class="main">

			<%
			select case Request("action")
			case "add"
			call raidplan_addsql("new")
			case "del"
				if IsNumeric(Request("id")) then
					call raidplan_delsql(Request("id"))
				end if
			case "newplan"
			call raidplan_add()
			case "edit"
				if IsNumeric(Request("id")) then
				call raidplan_edit(Request("id"))
				end if
			case "editsql"
				call raidplan_addsql(Request("id"))
			case else
			Response.write "..."
			end select
			%>
  </div>
<div id="footer"><!--#include file="footer.asp"--></div>

</body>
</html>
<%
SUB raidplan_add()
	Response.write "<form action='?action=add' method='post'>"
	Response.write "<table class='outframe interlace'>"
	Response.write "<tr><th colspan='2'><div class='title'><img src='images/icon/note.jpg' >填写活动基本信息</div></th></tr>"
	Response.write "<tr><td>活动主题*</td><td><input type='input' name='raid_name' value='' size='35'/></td></tr>"
	Response.write "<tr><td>DKP分类*</td><td>"&formselect("raid_class","id","class_name"," ")&"</td></tr>"
	Response.write "<tr><td>集合时间*</td><td><input type='input' name='raid_concentratetime' size='28' value=''/> 格式: "&now()&"</td></tr>"
	Response.write "<tr><td>行动时间*</td><td><input type='input' name='raid_actiontime' size='28' value=''/></td></tr>"
	Response.write "<tr><td>结束时间*</td><td><input type='input' name='raid_endtime' size='28' value=''/></td></tr>"
	Response.write "<tr><td>人数要求*</td><td><input type='input' name='raid_personnel' value=''/> 可以填写副本的最大人数</td></tr>"
	Response.write "<tr><td>DKP规则*</td><td>"&formselect("ruler","id","ruler_name"," ")&"</td></tr>"
	Response.write "<tr><td>指 挥 官</td><td><input type='input' name='raid_commander' value=''/></td></tr>"
	Response.write "<tr><td>备 注</td><td><textarea name='raid_plan' rows='8' cols='50'></textarea></td></tr>"
	Response.write "<tr><td></td><td><input type='submit' value='确定'/></td></tr>"
	Response.write "</table>"
	Response.write "</form>"
END SUB

SUB raidplan_edit(id)
	sql="select * from raid where id="&id
	rs.open sql,conn,1,1
	if rs.bof or rs.eof then
		Response.write "<h4>内部错误 C000010</h4>"
	else
		Response.write "<form action='?action=editsql' method='post'>"
		Response.write "<table class='outframe interlace'>"
		Response.write "<tr><th colspan='2'><div class='title'><img src='images/icon/note.jpg' >修改活动基本信息</div></th></tr>"
		Response.write "<tr><td>活动主题*</td><td><input type='input' name='raid_name' value='"&rs("raid_name")&"' size='35'/></td></tr>"
		Response.write "<tr><td>DKP分类*</td><td>"&formselect("raid_class","id","class_name",rs("raid_class"))&"</td></tr>"
		Response.write "<tr><td>集合时间*</td><td><input type='input' name='raid_concentratetime' size='28' value='"&rs("raid_concentratetime")&"'/> 格式: 2005-09-28 19:30:00</td></tr>"
		Response.write "<tr><td>行动时间*</td><td><input type='input' name='raid_actiontime' size='28' value='"&rs("raid_actiontime")&"'/></td></tr>"
		Response.write "<tr><td>结束时间*</td><td><input type='input' name='raid_endtime' size='28' value='"&rs("raid_endtime")&"'/></td></tr>"
		Response.write "<tr><td>人数要求*</td><td><input type='input' name='raid_personnel' value='"&rs("raid_personnel")&"'/></td></tr>"
		Response.write "<tr><td>DKP规则*</td><td>"&formselect("ruler","id","ruler_name",rs("raid_ruler"))&"</td></tr>"
		Response.write "<tr><td>指 挥 官</td><td><input type='input' name='raid_commander' value='"&rs("raid_commander")&"'/></td></tr>"
		Response.write "<tr><td>详细计划</td><td><textarea name='raid_plan' rows='8' cols='50'>"&rs("raid_plan")&"</textarea></td></tr>"
		Response.write "<tr><td></td><td><input type='submit' value='确定'/><input type='hidden' name='id' value='"&rs("id")&"' size='35'/></td></tr>"
		Response.write "</table>"
		Response.write "</form>"
	end if
	rs.close
END SUB

sub raidplan_addsql(s)
	'添加新的分类
	'验证提交数据有效性
	'数据库字段:
	Dim errorinfo
	if request("raid_name")="" then errorinfo=errorinfo & "<li>活动名称请不要留空.</li>"
	if request("raid_concentratetime")="" or request("raid_actiontime")="" or request("raid_endtime")="" then 
		errorinfo=errorinfo & "<li>活动的各个时间项不能为空.</li>"
	else
		if Datediff("m",request("raid_actiontime"),request("raid_endtime"))<0 then errorinfo=errorinfo & "<li>结束时间不能在开始时间之前</li>"
	end if
	if request("raid_name")="" then errorinfo=errorinfo & "<li>活动名称请不要留空.</li>"
	if not IsDate(request("raid_concentratetime")) then errorinfo=errorinfo & "<li>集结的时间格式不正确,请参考旁边的格式</li>"
	if not IsDate(request("raid_actiontime")) then errorinfo=errorinfo & "<li>行动的时间格式不正确,请参考旁边的格式</li>"
	if not IsDate(request("raid_endtime")) then errorinfo=errorinfo & "<li>结束时间格式不正确,请参考旁边的格式</li>"
	if not IsNumeric(request("raid_personnel")) then errorinfo=errorinfo & "<li>人员数量必须为数字</li>"
	if request("ruler_name")="" then errorinfo=errorinfo & "<li>请选择一个DKP规则,如果没有请先建立.</li>"
	'if IsValidEmail(request("L_AuthorMail"))<>"true" and request("L_AuthorMail")<>"" then errorinfo=errorinfo & "<li>无效的邮箱地址.</li>"
	'验证///

	if errorinfo<>"" then
		'抛出错误提示
		Response.write "<p>表单信息有误,提示如下:</p><ul>"&errorinfo&"</ul>"
		Response.write "请<a href='"&Url&"'>返回</a>重新修改."
	else
		'写入数据库
		if IsNumeric(s) then
			Sql="Select * from raid where id="&s
			rs.open sql,conn,1,3
			if rs.bof or rs.eof then exit sub
		else
			Sql="Select * from raid where (id is null)"
			rs.open sql,conn,1,3
			rs.addnew
			rs("raid_player")=""
		end if
		rs("raid_name")=trim(request("raid_name"))
		rs("raid_class")=trim(request("class_name"))
		rs("raid_concentratetime")=trim(request("raid_concentratetime"))
		rs("raid_actiontime")=request("raid_actiontime")
		rs("raid_endtime")=request("raid_endtime")
		rs("raid_personnel")=request("raid_personnel")
		rs("raid_ruler")=request("ruler_name")
		rs("raid_commander")=trim(request("raid_commander"))
		rs("raid_plan")=request("raid_plan")
		rs.update
		rs.close
		if IsNumeric(s) then
		call showmessage("修改完成 <a href='"&Url&"'>继续修改</a> | <a href='admin_report.asp'>查看列表</a> | <a href='raid_report.asp?id="&s&"'>查看该活动报告</a>")
		Else
			sql="select id from raid where raid_endtime=#"&request("raid_endtime")&"# order by id desc"
			rs.open sql,conn,1,1
			call showmessage("继续为活动<a href='/fsdkp/admin_report.asp?action=collect&id="&rs("id")&"'>添加成员</a>")
			rs.close
		end if
	end if
end sub


Sub raidplan_delsql(id)
	Sql="Delete from raid where id="&id
	conn.execute(sql)
	response.write "删除活动记录...<br>"
	Sql="Delete from dkplist where Raidid="&id
	conn.execute(sql)
	response.write "删除活动DKP缓存...<br>"
	Sql="Delete from raid_event where event_raidid="&id
	conn.execute(sql)
	response.write "删除活动事件....<br>"
	Sql="Delete from gbook where gbook_raidid='"&cstr(id)&"'"
	conn.execute(sql)
	response.write "删除活动留言....<br>"
	response.write "ALL DONE.<br>"
End Sub



%>